package com.atguigu.lease.common.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * projectName: com.atguigu.lease.common.mybatisplus
 *
 * @author: 顾司羽
 * time: 2024/12/9 11:36 周一
 * description:
 */
// @Component
@Configuration //这俩都可以，这个更好
public class MybatisMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        // this.strictInsertFill(metaObject, "属性名", 属性类型.class, 填充的值);
                                                // 属性名，不是列名
        this.strictInsertFill(metaObject,"createTime",Date.class,new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject,"updateTime",Date.class,new Date());
    }
}
